﻿namespace MXERP.Blazor.Components
{
    public partial class TabPanel : MudComponentBase
    {
        /// <summary>
        /// TabPanel's key
        /// </summary>
        [EditorRequired]
        [Parameter]
        public string Key { get; set; } = default!;
        [EditorRequired][Parameter] public string? Text { get; set; }
        [Parameter] public string Icon { get; set; } = Icons.Material.Filled.AutoAwesomeMosaic;
        [Parameter]public Color Color { get; set; } = Color.Default;
        [CascadingParameter] private Tabs? Parent { get; set; }
        [Parameter]public bool Closable { get; set; }
        [Parameter]public RenderFragment? ChildContent { get; set; }
        private bool _isActive;
        internal bool IsActive => _isActive;
        protected override void OnInitialized()
        {
            base.OnInitialized();
            Parent?.AddTabPanel(this);
        }
        internal void SetActive(bool isActive)
        {
            if (_isActive != isActive)
            {
                _isActive = isActive;
                //InvokeAsync(StateHasChanged);
            }
        }
    }
}
